vcSweptVolume
vcSweptVolume is a layout item used to measure and simulate volume displacement of moving objects and detect collisions.
See in: Overview
Module: vcCore
Parent: vcLayoutItem
Children -
Referenced by: -
Properties
Learn how to use properties here. The properties are also inherited from the parent class.
| Name | Type | Access | Description |
| Decomposition | vcSweptVolumeDecompositionType | RW | Gets or sets how many convex hulls created from included nodes.See moreFor example one convex hull encompassing all nodes or several convex hulls based on geometry of each node. |
| DecompositionDecimationTarget | Integer | RW | Gets or sets the target count for decimated triangle sets.See moreIf Decomposition set to vcSweptVolumeDecompositionType.DECOMPOSITION, sets the number of triangle sets remaining after decimation process of input nodes with fewer triangle sets than decimation target, thereby allowing you to expedite/speed up the process. Set to zero to have no effect. |
| DecompositionQuality | Real | RW | Gets or sets the quality target for decomposed mesh.See moreIf Decomposition set to vcSweptVolumeDecompositionType.DECOMPOSITION, sets the quality of decomposition in range 0 to 100, thereby affecting the approximation of convex hulls to the shape of input node geometry. A higher value produces better approximation and convex-shaped triangle sets at the cost of increasing a component's data count and simulation performance. |
| InputNodeList | list | RW | Gets or sets the simulation nodes based on which the swept volume is created.See moreThe list and its contents are returned and assigned as a copies. Assign this property to apply any changes. |
| Material | vcMaterial | RW | Gets or sets the overall material applied to generated swept geometry. When set, this material overrides per-hull default materials for the stored volume result. |
| Method | vcSweptVolumeMethod | RW | Gets or sets the method used for generating convex hulls as swept geometry, for example hollow or filled convex hulls. Note: Each method type has about the same performance level. |
| TargetNode | vcNode | RW | Gets or sets the node used for containing swept geometry, which should be static and not move during simulation. |
Methods
Learn how to use methods here. The methods are also inherited from the parent class.
| Name | Return Type | Parameters | Description |
| begin | None | Optional Keyword[center = vcVector] | Starts swept volume process, thereby initiating decomposition.See moreParameters: center (vcVector): Defines a frame of reference or center point in input node. If omitted, process uses center point of input node bound box. Exceptions: RuntimeError: When TargetNode or InputNodeList have incorrect values. |
| clear | None | None | Removes all swept geometry of layout item from 3D world. |
| end | None | None | Stops swept volume process. After swept volume process has ended, you can perform capping of swept geometry. Exceptions: RuntimeError: When TargetNode or InputNodeList have incorrect values. |
| next | None | Optional Keyword[center = vcVector] | Executes an iterative process that renders swept geometry based on positions of input nodes.See moreThat is, you should call this method each time you want to render swept volume in 3D world during swept process. Parameters: center (vcVector): Defines a frame of reference or center point in input node as it moves during a simulation. If omitted, process uses center point of input node bound box. Generally, this is used to offset swept geometry. Exceptions: RuntimeError: When TargetNode is None. |
| store | vcFeature | None | Stores swept geometry in TargetNode, thereby allowing you to save swept geometry in component and/or layout.See moreGenerally, you should call store() method after calling end() method and before clear() method. Returns: vcFeature: The Geometry feature where swept volume is stored in TargetNode. The naming convention for feature is VC_SweptVolumeResult, and the feature is an immediate child of TargetNode root feature. None if no swept geometry has been generated. Exceptions: RuntimeError: When TargetNode is None. |
Example: Basic Swept Volume
import vcCore as vc comp = vc.getComponent() world = vc.getWorld() sv = None def start_sweep(): """Initializes and returns a swept volume layout item""" #Create swept volume object sv = world.findLayoutItem('swept') if sv is None: sv = world.createLayoutItem(vc.vcLayoutItemType.SWEPT_VOLUME) sv.Name = 'swept' #Setup nodes to include/exclude in node list and scope target_name = "Sanding Tool" nodes = comp.findNode(target_name) if nodes is None: print("Failed to find node with name: {}".format(target_name)) return None entry = vc.vcNodeListEntry.new() entry.Node = nodes entry.Type = vc.vcNodeListEntryType.INCLUDE entry.Scope = vc.vcNodeListEntryScope.NODE sv.InputNodeList = [entry] #List of vcNodeListEntires #Set Decomposition and Method sv.Decomposition = vc.vcSweptVolumeDecompositionType.CONVEXHULL # DECOMPOSITION | CONVEXHULL | CONVEXHULL_TRIMESH sv.Method = vc.vcSweptVolumeMethod.HULL_FROM_HULLS_V2 # LOFTING, HULL_FROM_HULLS, HULL_FROM_SILHOUETTES, HULL_FROM_HULLS_V2 #Define container of swept volume geometry (must be static/not move) sv.TargetNode = comp return sv async def OnRun(): """Executed when the simulation is running""" global sv sv = start_sweep() if sv is None: return sv.begin() while True: sv.next() await vc.delay(0.05) #Defines how often the swept volume is updated def OnStop(): """Stop updating the swept volume when the simulation is stopped""" if sv is not None: sv.end() def OnReset(): """Remove swept volume as needed. Note that the generated swept volume is parented to target node""" if sv is not None: sv.clear()
Example: Robot Tool Swept Volume
import vcCore as vc comp = vc.getComponent() world = vc.getWorld() sim = vc.getSimulation() finalized = False sweptdefinition = None def OnFinalize(): """Triggered when the component is loaded/initialized. Initializes the swept volume""" global follownode, boundcenter, sweptdefinition, finalized if finalized: return # Change the name of the node according to your model target_name = "Sanding Tool" follownode = world.findComponent(target_name) if follownode is None: print("Failed to find node with name: {}".format(target_name)) return boundcenter = follownode.BoundingBox.Center # You may also want to change the name of the layout item. # Keep it specific in case you have multiple items sweptdefinition = world.findLayoutItem("PressGripperSweptDefintion") if(sweptdefinition): sweptdefinition.delete() sweptdefinition = world.createLayoutItem(vc.vcLayoutItemType.SWEPT_VOLUME) sweptdefinition.Name = "PressGripperSweptDefintion" # The following entry includes only the target node to be included entry = vc.vcNodeListEntry.new() entry.Node = follownode entry.Type = vc.vcNodeListEntryType.INCLUDE entry.Scope = vc.vcNodeListEntryScope.NODE sweptdefinition.InputNodeList = [entry] #List of vcNodeListEntires # Create a node in component to consist of the swept volume only. # This is handy when defining collision queues sweptnode = comp.findNode('Swept') if not sweptnode: sweptnode = comp.createLink('Swept') sweptdefinition.TargetNode = sweptnode # This is the fastest combination of method and decomposition to generate swept volume sweptdefinition.Decomposition = vc.vcSweptVolumeDecompositionType.CONVEXHULL # DECOMPOSITION | CONVEXHULL | CONVEXHULL_TRIMESH sweptdefinition.Method = vc.vcSweptVolumeMethod.HULL_FROM_HULLS # LOFTING, HULL_FROM_HULLS, HULL_FROM_SILHOUETTES, HULL_FROM_HULLS_V2 finalized = True def OnReset(): """Triggered when the simulation is reset. Tell the Swept Definition to clear recording""" if sweptdefinition: sweptdefinition.clear() def OnStart(): """Tell the Swept Definition to start recording""" OnFinalize() sweptdefinition.begin(follownode.WorldPositionMatrix * boundcenter) def OnSimulationUpdate(time): """Tell the Swept Definition to record one step""" if finalized and sim.IsRunning: sweptdefinition.next(follownode.WorldPositionMatrix * boundcenter) def OnStop(): """Tell the Swept Definition to stop recording""" if sweptdefinition: sweptdefinition.end()